package com.zhangyu.shadow.repair.delegate.search;

import android.support.annotation.Nullable;
import android.util.TypedValue;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.zhangyu.shadow.repair.R;

import java.util.List;

/**
 * Description:
 *
 * @author Hequn.Lee
 * @date 2018/11/15
 */
public class FlexDateAdapter extends BaseQuickAdapter<String, BaseViewHolder> {

    private OnDateChooseListener mOnClickListener;
    private boolean isPad;

    public FlexDateAdapter(int layoutResId,
                           @Nullable List<String> data,
                           OnDateChooseListener onClickListener,
                           boolean isPad) {
        super(layoutResId, data);
        mOnClickListener = onClickListener;
        this.isPad = isPad;
    }

    @Override
    protected void convert(BaseViewHolder helper, final String item) {
        helper.getView(R.id.text).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mOnClickListener != null) {
                    mOnClickListener.onChoose(item);
                }
            }
        });
        helper.setText(R.id.text, item);
        if (isPad) {
            ((TextView) helper.getView(R.id.text)).setTextSize(TypedValue.COMPLEX_UNIT_SP, 16);
        }
    }

    public interface OnDateChooseListener {
        void onChoose(String item);
    }
}
